﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class TestUI : MonoBehaviour
{
    public Button uiButton;
    public Image uiImage;
    private void Start()
    {
        //EventTrigger.Entry entry = new EventTrigger.Entry();
        //entry.eventID = EventTriggerType.PointerClick;  //定义为哪种触发事件
        //entry.callback.AddListener(Click);
        //GetComponent<EventTrigger>().triggers.Add(entry);
        uiButton.onClick.AddListener(Test);
    }
    private void Test()
    {
        Debug.Log("111");
    }
    public void Click(BaseEventData go)
    {
        Debug.Log(go);

    }

    void OnGUI()
    {

        if (GUILayout.Button("Auto Button"))
        {
            //ExecuteEvents.Execute<IPointerClickHandler>(uiButton.gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
            ExecuteEvents.Execute<ISubmitHandler>(uiButton.gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.submitHandler);
        }

        if (GUILayout.Button("Auto Image"))
        {
            ExecuteEvents.Execute<IPointerClickHandler>(uiImage.gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
        }

    }
}
